package com.sgsg.statemodule;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;


/***
 * 状态模式
 *当一个对象的内在状态改变时允许改变其行为，这个对象看起来像是改变了其类
 *主要解决的是当控制一个对象状态转换的条件表达式过于复杂时，把状态的判断逻辑
 * 转移到表示不同状态的一系列类中，可以把复杂的判断逻辑简化
 *
 */
public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Work work = new Work();
        work.setTaskFinished(true);
        work.setHour(11);
        work.writeProgram();
        work.setHour(12);
        work.writeProgram();
        work.setHour(14);
        work.writeProgram();
        work.setHour(16);
        work.writeProgram();
        work.setHour(18);
        work.writeProgram();
        work.setHour(15);
        work.writeProgram();
        work.setHour(20);
        work.writeProgram();
        work.setTaskFinished(false);
        work.setHour(22);
        work.writeProgram();

        work.setHour(23);
        work.writeProgram();
    }
}
